class Car():
    def __init__(self, make, model, year): # 初始化描述汽车的属性

        self.make = make
        self.model = model
        self.year = year
        self.odometer_reading = 0

    def get_descriptive_name(self): # 返回整洁的描述性信息
        long_name = str(self.year) + ' ' + self.make + ' ' + self.model
        return long_name.title()

    def read_odometer(self): # 打印一条指出汽车里程的消息
        print("This car has " + str(self.odometer_reading) + " miles on it.")

    def fill_gas_tank(self): # 打印一条指出汽车里程的消息
        print("This car has " + str('11') + " gas on it.")

    def update_odometer(self, mileage): # 设置里程表读数
        if mileage >= self.odometer_reading:
            self.odometer_reading = mileage
        else:
            print("You can't roll back an odometer!")

    def increment_odometer(self, miles): # 增加里程
        self.odometer_reading += miles


class ElectricCar(Car): # 创建子类时，父类必须包含在当前文件中，且位于子类前面

    def __init__(self, make, model, year): # 初始化父类的属性
        super().__init__(make, model, year) # super()函数是一个特殊函数，帮助Python将父类和子类关联起来

        # 添加子类属性
        self.battery_size = 70

    # 添加子类方法
    def describe_battery(self): # 打印一条描述电瓶容量的消息
        print("This car has a " + str(self.battery_size) + "-kWh battery.")

    def fill_gas_tank(self): # 重写父类的方法
        print("This car doesn't need a gas tank!")


my_tesla = ElectricCar('tesla', 'model s', 2016)
print(my_tesla.get_descriptive_name())
my_tesla.describe_battery()
my_tesla.fill_gas_tank()